package com.yoga.admin.api.web;

import com.yoga.admin.api.annotation.LoginUser;
import com.yoga.common.appexception.AppException;
import com.yoga.common.appexception.YogaResult;
import com.yoga.common.bo.PlainVipBO;
import com.yoga.common.bo.RenewPlainVipBO;
import com.yoga.common.bo.YogaAdminBO;
import com.yoga.manager.admin.AdminPlainVipManager;
import com.yoga.manager.admin.impl.AdminPlainVipManagerImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by hdx on 2020/10/21.
 */
@RestController
@RequestMapping("${basePath}")
public class AdminPlainVipController {

    @Resource
    public AdminPlainVipManager plainVipManager;

    @PostMapping("/plainVip/open")
    public YogaResult<Boolean> openPlainVip(@LoginUser YogaAdminBO adminBO, @RequestBody PlainVipBO plainVipBO) throws AppException {
        Boolean result = plainVipManager.openPlainVip(plainVipBO);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/renew")//会员续卡
    public YogaResult<Boolean> renewPlainVip(RenewPlainVipBO renewPlainVipBO) throws AppException {
        Boolean result = plainVipManager.renewPlainVip(renewPlainVipBO);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/stop")
    public YogaResult<Boolean> stopPlainVip(Long plainVipId, Integer month) throws AppException {
        Boolean result = plainVipManager.stopPlainVip(plainVipId, month);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/updateData")
    public YogaResult<Boolean> updateData(PlainVipBO plainVipBO) throws AppException {
        Boolean result = plainVipManager.updateData(plainVipBO);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/cutClassNum")
    public YogaResult<Boolean> cutClassNum(Long plainVipId) throws AppException {
        Boolean result = plainVipManager.cutClassNum(plainVipId);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/addClassNum")
    public YogaResult<Boolean> addClassNum(Long plainVipId) throws AppException {
        Boolean result = plainVipManager.addClassNum(plainVipId);

        return new YogaResult<>(result);
    }

    @PostMapping("/plainVip/getByUserId")
    public YogaResult<PlainVipBO> getByUserId(Long yogaUserId) throws AppException {
        PlainVipBO result = plainVipManager.getByUserId(yogaUserId);

        return new YogaResult<>(result);
    }

}
